
A.event =
{
    /* */
    events: [],

    /* */
    subscribe: function(name, callback)
    {
        var subscribers = this.events[name];
        if (!subscribers)
        {
            subscribers = this.events[name] = [];
        }

        subscribers.push(callback);
    },

    /* */
    unsubscribe: function(name, callback)
    {
        var subscribers = this.events[name];
        if (subscribers)
        {
            for(var i in subscribers)
            {
                if (subscribers[i] == callback)
                {
                    subscribers.splice(i,1);
                }                
            }
        }
    },

    /* */
    happened: function(name, data)
    {
        var subscribers = this.events[name];
        if (subscribers)
        {
            for(var i in subscribers)
            {
                if (subscribers[i])
                {
                    subscribers[i](data);
                }
            }
        }
    }
};